class GraphThemeLayer{
  /**
   * 构造专题图表图层类
   * @param map 地图对象
   * @param layerName 图层名称
   * @param datas 绑定数据（FeatureCollection）
   * @param options 图表样式
   * @param chartType 图表类型（Bar,Pie...）
   */
  constructor(map, layerName,datas,options,chartType) {
    this.map = map;
    this.layerName = layerName +'graphThemeLayer';
    this.chartsType = chartType
    options.id = layerName +'graphThemeLayer';
    this.options = options;
    this.layerId = layerName +'graphThemeLayer';;
    this.data = data || {};
  }


  add() {
    this.themeLayer = new mapboxgl.supermap.GraphThemeLayer(this.layerName, this.chartsType, this.options);
    this.map.addLayer(this.themeLayer);
    this.themeLayer.addFeatures(this.data);
  }

  clear() {
    const { map, options } = this;
    const layerId = options.id;
    if (map && layerId && map.getLayer(layerId)) {
      map.removeLayer(layerId);
    }
  }
}

export {GraphThemeLayer}
